<?php

namespace login\model;

class User {
	/**
	 * @var string
	 */
	private $username;
	/**
	 * @var string
	 */
	private $password;

	function __construct($username, $password) {
		$this->username = $username;
		$this->password = $password;
	}

	public function getUsername() {
		return $this->username;
	}

	public function getPassword() {
		return $this->password;
	}

	/**
	 * @throws Exception om något av användaruppgifterna är för korta eller innehåller taggar.
	 */
	public function checkUserCredentials() {
		if(empty($this->username)) {
			throw new \Exception("1");
		}
		if(empty($this->password)) {
			throw new \Exception("2");
		}
		if($this->username != strip_tags($this->username)) {
			throw new \Exception("3");
		}
		if($this->password != strip_tags($this->password)) {
			throw new \Exception("3");
		}
	}
}